commit: Don't require a subject
authorMathnerd314 <mathnerd314.gph+hs@gmail.com>
Mon, 23 May 2016 18:49:37 +0000 (12:49 -0600)
committerAtomic Bot <atomic-devel@projectatomic.io>
Wed, 25 May 2016 18:37:47 +0000 (18:37 +0000)
In practice, a lot of subjects are empty, because the commit date
and branch are sufficient identification. For example, rpm-ostree
does not use subjects. It also doesn't use the command-line ostree
commit tool, so this was not a problem there, but this makes the
behavior consistent.

Also adds a test that empty subjects and omitting the subject
are equivalent. The --timestamp is so that the commits do not
have different timestamps.

Closes: #305
Approved by: cgwalters

src/ostree/ot-builtin-commit.c
tests/basic-test.sh

index 99687c5262ed5755b49c9b5c1e982b38ed36ce2d..85c4c65d0a51e6035f01414f1b4e3c557a92db2b 100644 (file)
@@ -437,13 +437,6 @@ ostree_builtin_commit (int argc, char **argv, GCancellable *cancellable, GError
         goto out;
     }
 
-  if (!opt_subject)
-    {
-      g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED,
-                           "A subject must be specified with --subject");
-      goto out;
-    }
-
   if (!ostree_repo_prepare_transaction (repo, NULL, cancellable, error))
     goto out;
 
index 0373fcbcd870e16f8074c07dea07a50c13b768d9..93f67f178d0c373a4c9ad6f0a50a4386692472bc 100755 (executable)
@@ -19,7 +19,7 @@
 
 set -euo pipefail
 
-echo "1..56"
+echo "1..57"
 
 $OSTREE checkout test2 checkout-test2
 echo "ok checkout"
@@ -103,6 +103,12 @@ $OSTREE commit -b test2-no-parent -s '' --parent=none $test_tmpdir/checkout-test
 assert_streq $($OSTREE log test2-no-parent |grep '^commit' | wc -l) "1"
 echo "ok commit no parent"
 
+cd ${test_tmpdir}
+empty_rev=$($OSTREE commit -b test2-no-subject -s '' --timestamp="2005-10-29 12:43:29 +0000" $test_tmpdir/checkout-test2-4)
+omitted_rev=$($OSTREE commit -b test2-no-subject-2 --timestamp="2005-10-29 12:43:29 +0000" $test_tmpdir/checkout-test2-4)
+assert_streq $empty_rev $omitted_rev
+echo "ok commit no subject"
+
 cd ${test_tmpdir}
 $OSTREE commit -b test2-custom-parent -s '' $test_tmpdir/checkout-test2-4
 $OSTREE commit -b test2-custom-parent -s '' $test_tmpdir/checkout-test2-4